# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=picom
pkgver=9.1
pkgrel=0
pkgdesc="X Compositor (a fork of compton)"
url="https://github.com/yshui/picom"
arch="all"
license="MIT AND MPL-2.0"
makedepends="libx11-dev libxcomposite-dev libxinerama-dev libxdamage-dev
	libconfig-dev pcre-dev libxrandr-dev dbus-dev libdrm-dev mesa-dev meson
	libev-dev libxdg-basedir-dev pixman-dev xcb-util-renderutil-dev
	xcb-util-image-dev asciidoc uthash-dev"
checkdepends="xvfb-run python3 python3-dev py3-pip py3-wheel libffi-dev dbus-x11"
subpackages="$pkgname-doc"
source="picom-$pkgver.tar.gz::https://github.com/yshui/picom/archive/v$pkgver.tar.gz"
options="net" # Installs test dependencies with pip

[ "$CARCH" = "riscv64" ] && options="$options textrels"

replaces="compton" # Backwards compatibility
provides="compton=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	abuild-meson \
		-Dwith_docs=true \
		build
	meson compile ${JOBS:+-j ${JOBS}} -C build
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build

	mkdir -p "$pkgdir/usr/share/doc/picom"
	install -m644 README* "$pkgdir/usr/share/doc/picom/"
	install -D -m644 "picom.sample.conf" "$pkgdir/etc/xdg/picom.conf.example"
}

check() {
	pip install xcffib dbus_next
	xvfb-run -s "-screen 0 640x480x24" build/src/picom --config picom.sample.conf --no-vsync --diagnostics
	xvfb-run -s "+extension composite" -a ./tests/run_tests.sh build/src/picom
}

sha512sums="
375dc245be1c0f277bc0ddfc6e6480255efba06ce49f953c5314b7ba9795d1f50c5de907762208becc13c5210f24ac5b2241e2eb5e0e10dc5e5b96081cc821df  picom-9.1.tar.gz
"
